// 创建路由实例 createRouter
// 创建路由模式: hash\历史模式
import {createRouter,createWebHashHistory } from 'vue-router'

// 静态导入layout框架组件
import Layout from "@/layout/Layout.vue";

// 配置项、和组件路由的一一对应关系
export const routes = [
    {path: '/', redirect: '/base'}, // 重定向
    {path: '/login', component: ()=>import('@/login/index.vue')}, // 重定向
    {
        path: '/',
        component: Layout, //配置组件
        children: [
            {
                path: '/base',
                component: ()=> import('@/views/base/index.vue'),
                mate:{
                    role: ['admin'],
                    title: '基础'
                }
            },
            {
                path: '/base_directive',
                component: ()=> import('@/views/base-directive/index.vue')
            },
            {
                path: '/scc_scope',
                component: ()=> import('@/views/scc-scoped/index.vue')
            },
            {
                path: '/setup',
                component: ()=> import('@/views/setup/index.vue')
            },
            {
                path: '/pinia',
                component: ()=> import('@/views/pinia/index.vue')
            }
        ]
    }
]

//创建路由实例
const router = createRouter({
    routes, //路由项目配置
    history: createWebHashHistory(), //模式配置
})

// 全局路由守卫
router.beforeEach((to,from)=>{
    console.log(from,to)
    //return false 则不放行
    return undefined;
})

//导出路由实例
export  default  router